home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 1296 / text0000.txt < prev   
Encoding:
Text File  |  1996-08-05  |  2.2 KB  |  68 lines

  1. howard daniel joseph wrote:
  2. >         Okay. I'm writing a program under GCC on my Amiga.
  3. >         But I'm confused to hell over integer limits.
  4. >         My book talks about 2 bit and 4 bit integers ... and four bit
  5. > integers like what it describers long integers to be. Of course there's
  6. > unsigned integers and the like too.
  7. I think it should be 2 bytes integer which his 16 bits or 4 bytes integer 
  8. which has 32 bits.
  9.  
  10. > How do I declare signed versus unsigned integers?
  11.  
  12. int x;  // signed
  13. unsigned int x; // unsigned
  14. > How do I know how many bits my integers are using?
  15. sizeof(int); will give you the bytes your integers are using.
  16.  
  17. > How do I declare signed and unsigned long integers?
  18. long x;  // signed
  19. unsigned logn x; // unsigned
  20.  
  21. > What's with these "doubles" the book mysteriously alludes to?
  22. If you happen to know something about the data representation inside
  23. computer, you will understand why.
  24.  
  25. > What *am* I creating when I type;
  26. > int somevalue;
  27. > (ie Is it signed/unsigned? How many bits?)
  28. signed, but the size is determined by your computer and your compiler.
  29. On the sun workstations in the lab, the size is four bytes or 32 bits.
  30.  
  31. > I know many of the answers here, but if I could get them all from one
  32. > source I'd feel a lot better.
  33. > I need two sorts of values for my project;
  34. > An integer (unsigned) that can handle, 6, though ideally 9 places (Just
  35. > under 250000000 would be the maximum forseen possible value here.)
  36.  
  37. The largest unsigned int is 65536*65536 - 1.
  38. > An integer that can handle a much bigger number ... 12 places at least for
  39. > now.
  40. > Can I perform simple maths (addition, division) between integers of
  41. > different types? I'd assume so, right?
  42. Yes, you can.  But they will be converted according to the order of the
  43. evaluation of the expression.  You may lose precision sometimes.
  44.  
  45. Mu Han
  46. > --
  47. > =====///====================================================================
  48. > ====///=======This message brought to you by dannyman@uiuc.edu==============
  49. > \\\///=========HOME PAGE! http://www.uiuc.edu/ph/www/djhoward ==============
  50. > =\XX/A1200==================================================================
  51. >     My views are my own, and not those of my employer or UIUC. Happy Jim?
  52.  
  53.